<template>
  <el-radio-group
    :value="radioValue"
    @input="handleChange"
    :disabled="disabled"
    size="mini"
    :active-color="color.active"
    :inactive-color="color.inactive"
  >
    <el-radio-button
      v-for="item in options"
      :key="item.value"
      :label="item.value"
    >
      {{ item.label }}
    </el-radio-button>
  </el-radio-group>
</template>
<script>
export default {
  name: 'CSwitch',
  components: {},
  props: {
    value: { type: String, default: '' },
    disabled: { type: Boolean, default: false },
    options: {
      type: Array,
      default() {
        return []
      }
    },
    color: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      radioValue: this.value
    }
  },
  computed: {},
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  activated() {},
  deactivated() {},
  beforeDestroy() {},
  destroyed() {},
  methods: {
    handleChange(val) {
      const cache = this.radioValue
      this.radioValue = val
      const valBack = () => {
        this.radioValue = cache
      }
      this.$emit('change', { val, valBack })
    }
  }
}
</script>
